<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/11/7
  Time: 15:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>addSupplier</title>
    <link href="${pageContext.request.contextPath}/statics/layui/layui/css/layui.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/statics/layui/layui/layui.js" charset="utf-8"></script>
</head>
<body>
    <div style="margin-top: 25px">
        <form class="layui-form" action="addSupplier" method="post" enctype="multipart/form-data" style="width: 100%">
            <div class="layui-form-item">
                <label class="layui-form-label">供货商编号：</label>
                <div class="layui-input-inline">
                    <input type="text" name="supCode" id="supCode" lay-verify="required" placeholder="请输入供货商编号" autocomplete="off" class="layui-input">
                    <span style="color: red">${supCodeError}</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">供货商名称：</label>
                <div class="layui-input-inline">
                    <input type="text" name="supName" id="supName" lay-verify="required" placeholder="请输入供货商名称" autocomplete="off" class="layui-input">
                    <span style="color: red">${supNameError}</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">供货商描述：</label>
                <div class="layui-input-inline">
                    <input type="text" name="supDesc" id="supDesc" lay-verify="required" placeholder="请输入供货商描述" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">供货商联系人：</label>
                <div class="layui-input-inline">
                    <input type="text" name="supContact" id="supContact" lay-verify="required" placeholder="请输入供货商联系人" autocomplete="off" class="layui-input">
                    <span style="color: red">${supContactError}</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系电话：</label>
                <div class="layui-input-inline">
                    <input type="text" name="supPhone" id="supPhone" lay-verify="required" placeholder="请输入联系电话" autocomplete="off" class="layui-input">
                    <span style="color: red">${supPhoneError}</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">供货商地址：</label>
                <div class="layui-input-inline">
                    <input type="text" name="supAddress" id="supAddress" lay-verify="required" placeholder="请输入供货商地址" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">传真：</label>
                <div class="layui-input-inline">
                    <input type="text" name="supFax" id="supFax" lay-verify="required" placeholder="请输入传真" autocomplete="off" class="layui-input">
                    <span style="color: red">${supFaxError}</span>
                </div>
            </div>

            <div>
                图片：
                <input type="file" name="idPic">
            </div>

            <div class="layui-block">
                <div class="layui-input-block">
                    <button type="submit" id="sub" class="layui-btn" lay-submit="" >添加</button>
                </div>
            </div>
        </form>
    </div>

    <script>

        layui.use(['table','form','jquery','layer'], function(){
            var layer = layui.layer;
            var $ = layui.$;


           if (${msg==false}){
                layer.msg("添加失败",{
                    icon: 2,
                    time: 1000
                })
            }

            $('#supCode').blur(function () {
                $.get('codeExists?supCode='+this.value,function (data) {
                    if(data=='1'){
                        //存在
                        $('#supCode').next().html('该供货商已存在');
                        $('#sub').attr("disabled",true);
                    } else{
                        // 不存在
                        $('#supCode').next().html('');
                        $('#sub').attr("disabled",false);
                    }
                });
            });

        });

    </script>

</body>
</html>













